Source for file model.php
Documentation is available at model.php
* This file groups classes pertaining to the "model" part of MVC.
* @author Antoine d'Otreppe de Bouvette <a.dotreppe@aspyct.org>
* @license http://www.opensource.org/licenses/mit-license.php
* Generic attribute container class.
* Give an associative array to its constructor to define the existing fields.
* Defines and contains the existing fields.
* Returns the value of the attribute $attr.
* @throws DomainException if $attr does not exist.
public function __get($attr) {
return $this->attrs[$attr];
return $this->triggerAttributeError($attr);
* Returns the value of the attribute $attr.
* @throws DomainException if $attr does not exist.
public function __set($attr, $value) {
return $this->attrs[$attr] = $value;
return $this->triggerAttributeError($attr);
* Returns the attributes of this class in an associative array.
* Sets the value of attributes according to an associative array.
* No attribute will be added or deleted.
* Attributes not present in the array will be set to Null.
* Throws an exception stating that no such attribute exists.
* @throws DomainException
private function triggerAttributeError($attr) {
$cls = new ReflectionClass($this);
throw new DomainException(
'No attribute "' . $attr. '" in class ' . $cls->getName());
|